#include<iostream>
#include <string>
#include <ctime>
#include <pthread.h>
#include <vector>
#include <unistd.h>
//#include "mythread.hpp"
#include "LockGuard.hpp"
#include "BlockingQueue.hpp"
//using namespace ThreadClass;

using Data = int;
void* Consumer(void* args)
{
    BlockQueue<Data>* bq = static_cast<BlockQueue<Data>*>(args);
    while(true)
    {
        sleep(2);
        int data = 0;
        bq->pop(&data);
        std::cout<<"Consumer getdata-> "<<data<<std::endl;
    }
    return nullptr;
}
void* Producter(void* args)
{
    srand(time(nullptr) ^ 13143);
    BlockQueue<Data>* bq = static_cast<BlockQueue<Data>*>(args);
    while(true)
    {
        int data = rand() % 10 + 1;
        bq->push(data);
        std::cout<<"productor data -> "<<data<<std::endl;
    }
    return nullptr;
}
int main()
{
    BlockQueue<Data>* bq = new BlockQueue<Data>();
    pthread_t client,server;
    pthread_create(&server,nullptr,Producter,bq);
    pthread_create(&client,nullptr,Consumer,bq);
    pthread_join(client,nullptr);
    pthread_join(server,nullptr);
    return 0;
}